<nz-card>
  <div class="common-search-wrap">
    <div class="common-search-forms">
        <div class="common-form-item">
            <label class="common-search-label">综合搜索</label>
            <div class="common-search-conrol">
              <input nz-input placeholder="名称/标识/链接" [(ngModel)]="searchParams.name" />
            </div>
        </div>

        <div class="common-form-item">
          <div class="common-search-conrol">
            <button nz-button nzType="primary" class="m-r-8" [nzLoading]="tableParams.tableLoading" (click)="searchData()">查询</button>
            <button nz-button nzType="default" (click)="resetData()">重置</button>
          </div>
      </div>
    </div>
  </div>
</nz-card>

<nz-card class="m-t-2">
  <div class="operation-wrap p-b-15">
    <button nz-button nzType="primary" (click)="showModal(0)">新建映射</button>
  </div>

  <div class="pagination-wrap-position table-wrap">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.tableLoading"
      [nzData]="tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="100px">ID</th>
          <th nzAlign="center" nzWidth="250px">名称</th>
          <th nzAlign="center" nzWidth="250px">标识</th>
          <ng-container *ngFor="let item of mappingChannelOptions">
            <th nzAlign="center" nzWidth="260px">{{ item.label }}</th>
          </ng-container>
          <th nzAlign="center" nzWidth="200px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <td nzAlign="center">{{ data.id }}</td>
          <td nzAlign="center">{{ data.name || '-' }}</td>
          <td nzAlign="center">{{ data.key || '-' }}</td>
          <ng-container *ngFor="let item of mappingChannelOptions">
            <td nzAlign="center">{{ mappingFilter(item.value, data) }}</td>
          </ng-container>
          <td nzAlign="center" nzRight>
            <button nz-button nzType="link" (click)="showModal(1, data)">编辑</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>

<!-- S 新建编辑 -->
<nz-modal
  nzClassName="custom-model-wrap"
  [nzFooter]="null"
  [nzWidth]="620"
  [(nzVisible)]="isVisible"
  [nzTitle]="modalType === 0 ? '新增' : '编辑'"
  (nzOnCancel)="isVisible = false">

  <div *nzModalContent>
    <div class="custom-model-body">
      <!-- S body -->
      <nz-form-item nz-row>
        <nz-form-label nz-col nzSpan="6" nzRequired>名称</nz-form-label>
        <nz-form-control nz-col nzSpan="18">
          <input nz-input placeholder="请输入名称" [(ngModel)]="validateForm.name" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item nz-row>
        <nz-form-label nz-col nzSpan="6" nzRequired>标识</nz-form-label>
        <nz-form-control nz-col nzSpan="18">
          <input nz-input placeholder="请输入标识" [(ngModel)]="validateForm.key" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item nz-row>
        <nz-form-label nz-col nzSpan="6">备注</nz-form-label>
        <nz-form-control nz-col nzSpan="18">
          <nz-textarea-count [nzMaxCharacterCount]="100">
            <textarea rows="4" nz-input maxlength="100" placeholder="请输入备注" [(ngModel)]="validateForm.remarks"></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>

      <!-- <p class="modal-form-tip">下方链接，填写多个的话则可以一次性生成多个端的映射配置</p> -->

      <ng-container *ngFor="let item of mappingChannelOptions">
        <nz-form-item nz-row>
          <nz-form-label nz-col nzSpan="6">{{ item.label }}</nz-form-label>
          <nz-form-control nz-col nzSpan="18">
            <input nz-input placeholder="请输入..." [(ngModel)]="item.content" />
          </nz-form-control>
        </nz-form-item>
      </ng-container>
      <!-- E body -->
    </div>

    <div class="custom-model-foot">
      <div class="custom-foot-cont">
        <button nz-button nzType="default" (click)="isVisible = false">取消</button>
        <button nz-button nzType="primary" [nzLoading]="submitLoading" (click)="updateSubmit()">确定</button>
      </div>
    </div>
  </div>
</nz-modal>
<!-- E 新建编辑 -->